<!DOCTYPE html>
<html>
<title></title>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<link rel="stylesheet" href="assets/css/amazeui.min.css" />
<script src="assets/js/jquery.min.js"></script>
<script src="assets/js/amazeui.min.js"></script>
<script src="js/main.js"></script>
<script type="text/javascript"
	src="http://api.map.baidu.com/api?v=2.0&ak=58OECIIVagsFv6oxezDT8Xqo"></script>

<style>
html {
	height: 100%;
	overflow: hidden;
}

body {
	margin: 0;
	padding: 0;
	height: 100%;
}

#canvas {
	height: 100%;
}
</style>
</head>
<body>
	<header data-am-widget="header" class="am-header am-header-default">
		<div class="am-header-left am-header-nav">
			<a href="javascript:void(0)" onclick="doConfirm()"> <i
				class="am-header-icon am-icon-chevron-left"></i> </a>
		</div>
		<h1 class="am-header-title">
			<a href="#title-link" class=""> 定位确认 </a>
		</h1>

	</header>
	<div id="canvas"></div>
</body>

<script type="text/javascript">
	window.onload = function() {
		if (navigator.geolocation) {
			// 百度地图API功能
			var map = new BMap.Map("canvas");
			var point = new BMap.Point(116.331398, 39.897445);
			map.centerAndZoom(point, 12);

			var geolocation = new BMap.Geolocation();
			
			geolocation.getCurrentPosition(function(r) {
				if (this.getStatus() == BMAP_STATUS_SUCCESS) {
					
					var mk = new BMap.Marker(r.point);
					var mposition=r.point.lng+","+r.point.lat;
					window.sessionStorage.setItem("mposition", mposition);
					mk.enableDragging();
					mk.addEventListener("dragend", function(e) {
					mposition=e.point.lng+","+e.point.lat;
					window.sessionStorage.setItem("mposition", mposition);
					popConfirm('位置确认','确定该位置为商家地址?',function(){history.back();});
						//获取覆盖物位置
//						var o_Point_now = mk.getPosition();
//						var lng = o_Point_now.lng;
//						var lat = o_Point_now.lat;
//						console.log(lng+','+lat);
//						alert(lng+','+lat);
						//get_lng_lat();
					});			
					map.addOverlay(mk);
					map.panTo(r.point);
					//var p = mk.getPosition();  //获取marker的位置
					//alert('您的位置：' + p.point.lng + ',' + p.point.lat);	

				} else {
					alert('failed' + this.getStatus());
				}
			}, {
				enableHighAccuracy : true
			})
		}
	};
	function doConfirm(){
		popConfirm('位置确认','确定该位置为商家地址?',function(){history.go(-1);});
	}
</script>


</html>